<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>








<meta content="text/html; charset=UTF8" http-equiv="content-type">
<title>Simulation</title>
</head>
<body><%@page import="java.util.*"%>;
<%@page import="java.util.*"%>
<%@page import="java.sql.*"%>
<%@page
	import="hk.edu.cityu.is.riskmgmt.scheduler.*,hk.edu.cityu.is.riskmgmt.data.*"%>
<%
	String numberofbank = request.getParameter("numberofbank");
	String fxusd = request.getParameter("fxusd");
	String fxjpy = request.getParameter("fxjpy");
	String fxchf = request.getParameter("fxchf");
	String fxgbp = request.getParameter("fxgbp");
	String fxeur = request.getParameter("fxeur");
	String irusd = request.getParameter("irusd");
	String irjpy = request.getParameter("irjpy");
	String irchf = request.getParameter("irchf");
	String irgbp = request.getParameter("irgbp");
	String ireur = request.getParameter("ireur");
	String stockdji = request.getParameter("stockdji");
	String stockhsi = request.getParameter("stockhsi");
	String stockeur = request.getParameter("stockeur");
	String shockrate = request.getParameter("shock_rate");
	String pricing = request.getParameter("stockprice");
	String fxexp = request.getParameter("fxexp");
	String irexp = request.getParameter("irexp");
	String stockexp = request.getParameter("stockexp");
	String shockfreq = request.getParameter("shockfreq");
	String outflows = request.getParameter("outflows");

	ArrayList al = new ArrayList();
	Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
	String connectionUrl = "jdbc:sqlserver://localhost:1438;database=HKBANK;user=sa;password=1111";
	Connection conn = DriverManager.getConnection(connectionUrl);
	Statement stmt = conn
			.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
					ResultSet.CONCUR_UPDATABLE);
	String sql = "delete from configuration";
	String sql1 = "insert into configuration(numberofbank,fxusd,fxeur,fxgbp,fxchf,fxjpy,irusd,irchf,irjpy,ireur,irgbp,shockrate,dji,hsi,ftse,fxexp,irexp,stockexp,shockfreq) values(";
	String sql2 = numberofbank + "," + fxusd + "," + fxeur + ","
			+ fxgbp + "," + fxchf + "," + fxjpy + "," + irusd + ","
			+ irchf + "," + irjpy + "," + ireur + "," + irgbp + ","
			+ shockrate + "," + stockdji + "," + stockhsi + ","
			+ stockeur + "," + fxexp + "," + irexp + "," + stockexp
			+ "," + shockfreq + ")";
	System.out.println(sql1 + sql2);
	stmt.execute(sql);
	ResultSet rs = stmt.executeQuery(sql1 + sql2);
%>
<%
	new Thread() {
		public void run() {
			SharedData sd = new SharedData(); //sd.setBankno(Integer.parseInt(numberofbank));
			SimulationScheduler ss = new SimulationScheduler(sd);
			ss.start();
		}
	}.start();
%>
<script language="javascript">
	function fresh() {

		document.getElementById('frame1').src = 'CPVChart.jsp';
		document.getElementById('table1').src = 'table.jsp';
		//document.getElementById('frame2').src='CDSChart.jsp';
		window.parent['frame2'].location.reload();

		setTimeout("fresh()", 1000);
	}
	setTimeout("fresh()", 1000);
	//-->
	function changetodji() {
		document.getElementById('frame2').src = 'dji.jsp';
		//alert();
	}
	function changetohsi() {
		document.getElementById('frame2').src = 'hsi.jsp';
		//alert();
	}
	function changetofti() {
		document.getElementById('frame2').src = 'fti.jsp';
		//alert();
	}
	function changetocds() {
		document.getElementById('frame2').src = 'CDSChart.jsp';
		//alert();
	}
	function changetolegend() {
		document.getElementById('frame2').src = 'legend.htm';
		//alert();
	}
	function changetotable() {
		document.getElementById('frame2').src = 'table.jsp';
		//alert(
	}
	function changetobigtable() {
		document.getElementById('frame2').src = 'bigtable.jsp';
		//alert(

	}
</script>



<table style="text-align: left; width: 100%;" border="1" cellpadding="2"
	cellspacing="2">
	<tbody>
		<tr>
			<td style="vertical-align: top;"><span
				style="font-weight: bold;">Chart</span><br>
			</td>
			<td colspan="2" rowspan="1"
				style="vertical-align: top; font-weight: bold;">Bank Risk
			Simulation Model<br>
			</td>
		</tr>
		<tr>
			<td colspan="1" rowspan="1" style="vertical-align: top;"><br>
			</td>
			<td colspan="2" rowspan="1"
				style="vertical-align: top; text-align: center; width: 50%;"><a
				href="javascript:changetodji();">DJI</a> | <a
				href="javascript:changetohsi();">HSI</a> | <a
				href="javascript:changetofti();">FTSE 100</a> | <a
				href="javascript:changetocds();">CDS</a> | <a
				href="javascript:changetolegend();">Legend</a> | <a
				href="javascript:changetobigtable();">Table</a><br>
			<br>
			</td>
		</tr>
		<tr>
			<td style="vertical-align: top;"><iframe id="frame1"
				src="CPVChart.jsp" height="400" width="800"></iframe><br>
			</td>
			<td rowspan="1" colspan="2" style="vertical-align: top;"><iframe
				id="frame2" src="CDSChart.jsp" height="400" width="800"></iframe><br>
			</td>

		</tr>
		<tr>
			<td colspan="1" rowspan="6" style="vertical-align: top;">dd<br>
			<table style="text-align: left; width: 504px; height: 111px;"
				border="1" cellpadding="2" cellspacing="2">
				<tbody>
					<tr>
						<td style="vertical-align: top;"><img
							src="https://chart.googleapis.com/chart?cht=p3&chd=t:<%=fxusd%>,<%=fxeur%>,<%=fxgbp%>,<%=fxjpy%>,<%=fxchf%>&chs=250x150&chl=USD|EUR|GBP|JPY|CHF&chtt=FX" />
						</td>
						<td style="vertical-align: top;"><img
							src="https://chart.googleapis.com/chart?cht=p3&chd=t:<%=irusd%>,<%=ireur%>,<%=irgbp%>,<%=irjpy%>,<%=irchf%>&chs=250x150&chl=USD|EUR|GBP|JPY|CHF&chtt=Interest Rate" />
						</td>
						<td style="vertical-align: top;"><img
							src="https://chart.googleapis.com/chart?cht=p3&chd=t:<%=stockdji%>,<%=stockhsi%>,<%=stockeur%>&chs=250x150&chl=DJI|HSI|FTSE&chtt=Stock Exchange" /><br>
						</td>
					</tr>
				</tbody>
			</table>
			<br>

			</td>
			<td colspan="2" rowspan="1" style="vertical-align: top;"><span
				style="font-weight: bold;">Parameters &amp; Indictors</span><br>

			</td>

		</tr>
		<tr>
			<td style="vertical-align: top; font-weight: bold;"><iframe
				id="table1" src="table.jsp" width="780" height="300" marginwidth="0"
				marginheight="0" scrolling="no" frameborder="0"></iframe><br>
			</td>
		</tr>
	</tbody>
</table>

<br>

</body>
</html>